<template>
    <div>
        <div>
            <div>
                <el-button type="primary" @click="goPackageDialog">配包</el-button>
            </div>
        </div>
        <div>
            <el-table
                ref="multipleTable"
                :data="packageList"
                v-loading="packageLoading"
                tooltip-effect="dark"
                style="width: 100%"
                :row-style="{height: '0'}"
                :cell-style="{padding: '3px'}"
                max-height="500" border
                @selection-change="handleSelectionChangePackage">
                <!-- <el-table-column
                    type="selection"
                    width="55">
                </el-table-column> -->
                <el-table-column
                    label="配包"
                    width="80">
                    <template slot-scope="scope">配包{{ scope.row.addIndex }}</template>
                </el-table-column>
                <el-table-column
                    label="状态"
                    width="80">
                    <template slot-scope="scope">{{ scope.row.status && scope.row.status == 2 ? '已确认' : '待确认' }}</template>
                </el-table-column>
                <el-table-column
                    prop="totalPrice"
                    label="总货值"
                    width="100">
                </el-table-column>
                <el-table-column
                    prop="cost"
                    label="总成本"
                    width="100">
                </el-table-column>
                <el-table-column
                    label="媒体列表">
                    <template slot-scope="scope">
                        <el-table
                            :data="scope.row.lineList"
                            tooltip-effect="dark"
                            :row-style="{height: '0'}"
                            :cell-style="{padding: '3px'}"
                            border
                            style="width: 100%">
                            <el-table-column
                                prop="mediumName"
                                label="媒体名称"
                                width="120">
                            </el-table-column>
                            <el-table-column
                                prop="lineType"
                                label="媒体类型"
                                width="80">
                                <template slot-scope="mediumScope">{{ mediumScope.row.lineType && mediumScope.row.lineType == 1 ? '线上媒体' : '线下媒体' }}</template>
                            </el-table-column>
                            <el-table-column
                                prop="cost"
                                label="成本"
                                width="100">
                            </el-table-column>
                            <el-table-column
                                prop="totalPrice"
                                label="总货值"
                                width="100">
                            </el-table-column>
                            <el-table-column
                                label="总数"
                                width="60">
                                <template slot-scope="mediumScope">{{ mediumScope.row.lineType && mediumScope.row.lineType == 1 ? mediumScope.row.num : mediumScope.row.totalNum}}</template>
                            </el-table-column>
                            <el-table-column
                                label="剩余未排期"
                                width="60">
                                <template slot-scope="mediumScope">{{ mediumScope.row.lineType && mediumScope.row.lineType == 2 && mediumScope.row.hasJoinNum ? mediumScope.row.hasJoinNum : '/' }}</template>
                            </el-table-column>
                            <el-table-column
                                label="指定日期">
                                <template slot-scope="mediumScope">{{ mediumScope.row.lineType && mediumScope.row.lineType == 2 && mediumScope.row.dateString ? mediumScope.row.dateString : '/' }}</template>
                            </el-table-column>
                            <el-table-column
                                label="数量"
                                width="40">
                                <template slot-scope="mediumScope">{{ mediumScope.row.num2 ? mediumScope.row.num2 : '/' }}</template>
                            </el-table-column>
                        </el-table>
                    </template>
                </el-table-column>
                <el-table-column fixed="right" label="操作" width="100">
                    <template slot-scope="scope">
                        <div v-if="scope.row.status == 1">
                            <el-button @click="surePackage(scope.row)" type="text" size="small">确认配包</el-button>
                        </div>
                        <div v-if="scope.row.status == 2">
                            <el-button @click="showPackageByIndex(1, scope.row)" type="text" size="small">排期</el-button>
                        </div>
                        <div>
                            <el-button @click="updatePackage(scope.row)" type="text" size="small">修改</el-button>
                        </div>
                        <div>
                            <el-button @click="exportPackage(scope.row)" type="text" size="small">导出</el-button>
                        </div>
                        <div v-if="scope.row.status != 2">
                            <el-button @click="delPackage(scope.row)" type="text" size="small">删除</el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
        </div>

        
        
        <el-dialog title="选择媒体列表" :visible.sync="choosePackageDialog" width="85%" append-to-body>
            <div>
                <div style="font-size: 25px;font-weight: bolder;padding-bottom: 10px;">线上媒体</div>
                <div>
                    <ul class="global-operation-list" style="margin-top: 20px;">
                        <li class="global-operation-left">
        
                            <ul class="global-filter-list">
                                <li class="global-filter-item">
                                    <h2 class="global-filter-item-title">关键字：</h2>
                                    <el-input v-model="searchLineForm.keyword" 
                                    @change="getOnlinePost"
                                    placeholder="名称" clearable></el-input>
                                </li>
                                <li class="global-filter-item">
                                    <h2 class="global-filter-item-title">账号属性：</h2>
                                    <el-select
                                    v-model="searchLineForm.userType"
                                    placeholder="请选择"
                                    clearable
                                    >
                                        <el-option
                                            v-for="item in onlineUserType"
                                            :key="item.id"
                                            :label="item.sysValueName"
                                            :value="item.id">
                                        </el-option>
                                    </el-select>
                                </li>

                                <li class="global-filter-item">
                                    <el-button
                                    type="primary"
                                    class="global-filter-item-search"
                                    style="background: #03C192;border: none;"
                                    @click="rePostsOnline()"
                                    >搜索</el-button
                                    >
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
                <el-table
                    ref="onlineTable"
                    :data="dataOnlineList"
                    :row-key="get_row_key"
                    tooltip-effect="dark"
                :row-style="{height: '0'}"
                :cell-style="{padding: '3px'}"
                    border
                    style="width: 100%"
                    @selection-change="handleSelectionChangePackageOnlineList">
                    <el-table-column
                        type="selection"
                        :reserve-selection="true"
                        align="center"
                        width="55">
                    </el-table-column>

                    <el-table-column
                        prop="chooseNum"
                        label="数量"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <el-input v-model="scope.row.chooseNum" type="number" autocomplete="off"></el-input>
                        </template>
                    </el-table-column>

                    <el-table-column
                        prop="plateName"
                        label="名称"
                        show-overflow-tooltip
                    ></el-table-column>
                    
                    <el-table-column
                        label="账号属性"
                        prop="userTypeName"
                        show-overflow-tooltip
                    >
                    </el-table-column>
                    
                    <el-table-column
                        label="粉丝量级"
                        prop="fans"
                        show-overflow-tooltip
                    >
                    </el-table-column>
                    
                    <el-table-column
                        prop="cost"
                        label="成本"
                        show-overflow-tooltip
                    ></el-table-column>
                    
                    <el-table-column
                        prop="goodPrice"
                        label="匹配货值"
                        show-overflow-tooltip
                    ></el-table-column>

                    <el-table-column
                        prop="createType"
                        label="创作类型"
                        show-overflow-tooltip
                    ></el-table-column>
                    
                    <el-table-column
                        prop="remark"
                        label="备注"
                        show-overflow-tooltip
                    ></el-table-column>

                    <el-table-column
                        prop="steadyContent"
                        label="注意点"
                        show-overflow-tooltip
                    ></el-table-column>

                    <el-table-column
                        prop="pic"
                        label="图片"
                    >
                        <template slot-scope="scope">
                        <el-image
                            v-if="scope.row.pic"
                            style="width: 100px; height: 100px"
                            :src="scope.row.pic"
                            fit="fill"></el-image>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="global-page">
                    <div class="global-page-left">
                    </div>
                    <el-pagination
                    @current-change="handleCurrentChangeOnline"
                    :page-size="pageSizeOnline"
                    :current-page="pageNumOnline"
                    background
                    layout="total, prev, pager, next"
                    :total="totalOnline"
                    ></el-pagination>
                </div>
            </div>
            <el-divider></el-divider>
            <div style="padding-top: 20px;">
                <div style="font-size: 25px;font-weight: bolder;padding-bottom: 10px;">线下媒体</div>
                <div>
                    <ul class="global-operation-list" style="margin-top: 20px;">
                        <li class="global-operation-left">
                            <ul class="global-filter-list">
                                <li class="global-filter-item">
                                    <h2 class="global-filter-item-title">关键字：</h2>
                                    <el-input v-model="searchLineForm.offlineKeyword" 
                                    @change="getOfflinePost"
                                    placeholder="名称" clearable></el-input>
                                </li>
                                <li class="global-filter-item">
                                    <h2 class="global-filter-item-title">线下类型：</h2>
                                    <el-select
                                    v-model="searchLineForm.offlineType"
                                    placeholder="请选择"
                                    >
                                    <el-option
                                        v-for="item in offlineTypeList"
                                        :key="item.id"
                                        :label="item.sysValueName"
                                        :value="item.id">
                                    </el-option>
                                    </el-select>
                                </li>

                                <li class="global-filter-item">
                                    <el-button
                                        type="primary"
                                        class="global-filter-item-search"
                                        style="background: #03C192;border: none;"
                                        @click="rePostsOffline()"
                                        >搜索</el-button
                                    >
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
                <el-table
                    ref="offlineTable"
                    :data="dataOfflineList"
                    tooltip-effect="dark"
                    :row-key="get_row_key"
                :row-style="{height: '0'}"
                :cell-style="{padding: '3px'}"
                    border
                    style="width: 100%"
                    @selection-change="handleSelectionChangePackageOfflineList">
                    <el-table-column
                        type="selection"
                        :reserve-selection="true"
                        align="center"
                        width="55">
                    </el-table-column>

                    <el-table-column
                        prop="chooseNum"
                        label="刊数"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <el-input v-model="scope.row.chooseNum" autocomplete="off"></el-input>
                        </template>
                    </el-table-column>

                    <el-table-column
                        prop="num2"
                        label="数量"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <el-input v-model="scope.row.num2" autocomplete="off"></el-input>
                        </template>
                    </el-table-column>

                    <el-table-column
                        :prop="item.value"
                        :label="item.label"
                        show-overflow-tooltip
                        v-for="(item, index) in offlineModelMap[searchLineForm.offlineType]" :key="index"
                    >
                        <template slot-scope="scope">
                        {{ scope.row[item.value] }}
                        </template>
                    </el-table-column>

                    <el-table-column
                        prop="pic"
                        label="图片"
                    >
                        <template slot-scope="scope">
                        <el-image
                            v-if="scope.row.pic"
                            style="width: 100px; height: 100px"
                            :src="scope.row.pic"
                            :preview-src-list="[scope.row.pic]"
                            fit="fill"></el-image>
                        </template>
                    </el-table-column>
                    
                </el-table>
                <div class="global-page">
                    <div class="global-page-left">
                    </div>
                    <el-pagination
                    @current-change="handleCurrentChangeOffline"
                    :page-size="pageSizeOffline"
                    :current-page="pageNumOffline"
                    background
                    layout="total, prev, pager, next"
                    :total="totalOffline"
                    ></el-pagination>
                </div>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button @click="doSurePackageDialogVisible">确定</el-button>
                <el-button @click="choosePackageDialog = false">取消</el-button>
            </div>
        </el-dialog>

        
        <el-dialog title="日历" :visible.sync="dateCalendarDialog" width="95%" @closed="closeDateCalendarDialog" :destroy-on-close="destroyCloseDateCalendarDialog" append-to-body>
            <Calendar :project-id="projectId" :choose-show-add-index="chooseShowAddIndex" v-if="dateCalendarDialog" 
            :online-medium-list="onlineMediumList" 
            :offline-medium-list="offlineMediumList" :calendar-show-type="2" :project-choose-map="projectChooseMap" 
            :calendar-scroll-left-status="calendarScrollLeftStatus" :data-offline-list="dataPackageOfflineList" :calendar-type="calendarType"
            @scrollEndCalendar="scrollEndCalendar" @scrollStartCalendar="scrollStartCalendar" :calendar-start-time="calendarStartTime" 
            :calendar-end-time="calendarEndTime" @refushList="handlePackageRefush" @refushPackageList="handlePackage" :brands="brands" 
            :project-name="projectName"></Calendar>
        </el-dialog>
    </div>
</template>

<script>
import APIProject from "@/api/apiProject";
import APIMedium from "@/api/apiMedium";
import APIAdmin from "@/api/apiCompanyUser";
import APISysLabel from "@/api/apiSysLabel";
import Calendar from "@/components/calendar/Calendar";
export default {
    name: "ProjectPackage",
    components: {
        Calendar
    },
    props: {
        projectId: Number,
        packageDialogVisibleNum: Number,
        brands: String,
        projectName: String,
    },
    watch: {
        choosePackageDialog(val) {
            if(!val){
                this.cleanTableSelect()
            }
        },
        projectId(val){
            if(val){
                // this.chooseProjectId = val
                // this.handlePackage()
            }
        },
        packageDialogVisibleNum(val){
            if(val){
                this.chooseProjectId = this.projectId
                this.handlePackage()
            }
        },
    },
    created(){
    },
    data() {
        return {
            chooseProjectId: null,
            packageDialogVisible: false,
            packageList: [],
            choosePackageDialog: false,
            onlineUserType: [],
            offlineTypeList: [],
            dataOfflineList: [],
            dataOnlineList: [],
            searchLineForm: {
                offlineKeyword: '',
                userType: null,
                keyword: '',
                offlineType: null,
            },
            totalOffline: 0,
            totalOnline: 0,
            pageNumOffline: 1,
            pageSizeOffline: 10,
            pageNumOnline: 1,
            pageSizeOnline: 10,
            chooseOnlineList: [],
            chooseOfflineList: [],
            chooseAddIndex: null,
            dateCalendarDialog: false,
            dataPackageOfflineList: [],
            calendarStartTime: new Date().getTime(),
            calendarEndTime: new Date().getTime(),
            calendarType: 1,
            calendarScrollLeftStatus: true,
            destroyCloseDateCalendarDialog: false,
            projectChooseMap: {},
            onlineMediumList: [],
            offlineMediumList: [],
            chooseShowAddIndex: null,
            offlineModelMap: {
                519: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖地区",
                    value: "address",
                },
                {
                    label: "刊播秒数(秒)",
                    value: "publicationSeconds",
                },
                {
                    label: "时间",
                    value: "oneDayOperationTime",
                },
                {
                    label: "预估曝光量(次/天)",
                    value: "predictDayPersonNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                520: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖地区",
                    value: "address",
                },
                {
                    label: "播出频次(次/面/天)",
                    value: "broadcastFrequency",
                },
                {
                    label: "预估曝光量(次/天)",
                    value: "predictDayPersonNum",
                },
                {
                    label: "数量(台)",
                    value: "screenNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                521: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖地区",
                    value: "address",
                },
                {
                    label: "投放模式",
                    value: "putType",
                },
                {
                    label: "秒数、播出频次(次/面/天)",
                    value: "broadcastFrequency",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "数量(台)",
                    value: "screenNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                522: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖地区",
                    value: "address",
                },
                {
                    label: "模式",
                    value: "putType",
                },
                {
                    label: "备注",
                    value: "remark",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "数量(台)",
                    value: "screenNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                523: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖地区",
                    value: "address",
                },
                {
                    label: "刊播秒数(秒)",
                    value: "publicationSeconds",
                },
                {
                    label: "播出频次(次/面/天)",
                    value: "broadcastFrequency",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "数量(台)",
                    value: "screenNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                524: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖地区",
                    value: "address",
                },
                {
                    label: "刊播秒数(秒)",
                    value: "publicationSeconds",
                },
                {
                    label: "播出频次(次/面/天)",
                    value: "broadcastFrequency",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "数量(台)",
                    value: "screenNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                525: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖地区",
                    value: "address",
                },
                {
                    label: "卖场点位",
                    value: "screenPosition",
                },
                {
                    label: "秒数、播出频次(次/屏/天)",
                    value: "broadcastFrequency",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "数量(台)",
                    value: "screenNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                494: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖",
                    value: "address",
                },
                {
                    label: "屏幕数量",
                    value: "screenNum",
                },
                {
                    label: "刊播秒数(秒)",
                    value: "publicationSeconds",
                },
                {
                    label: "上刊时间",
                    value: "oneDayOperationTime",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                527: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖",
                    value: "address",
                },
                {
                    label: "屏幕数量",
                    value: "screenNum",
                },
                {
                    label: "刊播秒数(秒)",
                    value: "publicationSeconds",
                },
                {
                    label: "上刊时间",
                    value: "oneDayOperationTime",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                528: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖",
                    value: "address",
                },
                {
                    label: "屏幕数量",
                    value: "screenNum",
                },
                {
                    label: "刊播秒数(秒)",
                    value: "publicationSeconds",
                },
                {
                    label: "上刊时间",
                    value: "oneDayOperationTime",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                526: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖地区",
                    value: "address",
                },
                {
                    label: "播放时间",
                    value: "screenPosition",
                },
                {
                    label: "刊播秒数(秒)",
                    value: "publicationSeconds",
                },
                {
                    label: "场次",
                    value: "screenNum",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                529: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "覆盖地区",
                    value: "address",
                },
                {
                    label: "播放时间",
                    value: "screenPosition",
                },
                {
                    label: "刊播秒数(秒)",
                    value: "publicationSeconds",
                },
                {
                    label: "场次",
                    value: "screenNum",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                530: [
                {
                    label: "APP名称",
                    value: "name",
                },
                {
                    label: "覆盖",
                    value: "address",
                },
                {
                    label: "曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "展现形式",
                    value: "showTypeContent",
                },
                {
                    label: "位置",
                    value: "positionSpecs",
                },
                {
                    label: "备注",
                    value: "remark",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                496: [
                {
                    label: "高铁站名",
                    value: "name",
                },
                {
                    label: "所属城市",
                    value: "city",
                },
                {
                    label: "位置规格",
                    value: "positionSpecs",
                },
                {
                    label: "刊播秒数、频次",
                    value: "publicationSeconds",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "屏幕数量（面）",
                    value: "screenNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                534: [
                {
                    label: "高铁站名",
                    value: "name",
                },
                {
                    label: "所属城市",
                    value: "city",
                },
                {
                    label: "位置规格",
                    value: "positionSpecs",
                },
                {
                    label: "刊播秒数、频次",
                    value: "publicationSeconds",
                },
                {
                    label: "屏幕数量（面）",
                    value: "screenNum",
                },
                {
                    label: "预估日均客流量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "预估合计曝光量",
                    value: "broadcastFrequency",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                531: [
                {
                    label: "APP名称",
                    value: "name",
                },
                {
                    label: "覆盖",
                    value: "address",
                },
                {
                    label: "展示方式",
                    value: "showTypeContent",
                },
                {
                    label: "位置",
                    value: "screenPosition",
                },
                {
                    label: "预计曝光量pv",
                    value: "predictDayPersonNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                532: [
                {
                    label: "机场名",
                    value: "name",
                },
                {
                    label: "所属城市",
                    value: "city",
                },
                {
                    label: "广告形式",
                    value: "showTypeContent",
                },
                {
                    label: "刊播秒数、频次",
                    value: "publicationSeconds",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "屏幕数量（面）",
                    value: "screenNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                495: [
                {
                    label: "商场名",
                    value: "name",
                },
                {
                    label: "城市",
                    value: "city",
                },
                {
                    label: "屏幕位置",
                    value: "screenPosition",
                },
                {
                    label: "商场数量",
                    value: "marketNum",
                },
                {
                    label: "单个商场单周预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "预估合计曝光量",
                    value: "broadcastFrequency",
                },
                {
                    label: "展现形式",
                    value: "showTypeContent",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                497: [
                {
                    label: "机场名",
                    value: "name",
                },
                {
                    label: "位置规格",
                    value: "positionSpecs",
                },
                {
                    label: "刊播秒数、频次",
                    value: "publicationSeconds",
                },
                {
                    label: "屏幕数量（面）",
                    value: "screenNum",
                },
                {
                    label: "预估日均客流量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "预估合计曝光量",
                    value: "broadcastFrequency",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                533: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "城市",
                    value: "city",
                },
                {
                    label: "位置",
                    value: "positionSpecs",
                },
                {
                    label: "画面尺寸",
                    value: "oneDayOperationTime",
                },
                {
                    label: "秒数频次",
                    value: "publicationSeconds",
                },
                {
                    label: "屏幕数量*不可选点",
                    value: "screenNum",
                },
                {
                    label: "预估合计曝光量",
                    value: "broadcastFrequency",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                535: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "城市",
                    value: "city",
                },
                {
                    label: "位置",
                    value: "positionSpecs",
                },
                {
                    label: "画面尺寸",
                    value: "oneDayOperationTime",
                },
                {
                    label: "秒数频次",
                    value: "publicationSeconds",
                },
                {
                    label: "屏幕数量",
                    value: "screenNum",
                },
                {
                    label: "预估合计曝光量",
                    value: "broadcastFrequency",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
                498: [
                {
                    label: "名称",
                    value: "name",
                },
                {
                    label: "城市",
                    value: "city",
                },
                {
                    label: "位置",
                    value: "positionSpecs",
                },
                {
                    label: "显示屏规格（宽×高，单位：米）",
                    value: "oneDayOperationTime",
                },
                {
                    label: "秒数频次",
                    value: "publicationSeconds",
                },
                {
                    label: "预估曝光量",
                    value: "predictDayPersonNum",
                },
                {
                    label: "投放周期",
                    value: "putInCycle",
                },
                {
                    label: "成本",
                    value: "cost",
                },
                {
                    label: "匹配货值",
                    value: "goodPrice",
                },
                ],
            },
            packageLoading: false,
        };
    },
    methods: {
        surePackage(row){
            this.$confirm('是否确认使用该配包, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.handleClickSure(row)
                this.$message({
                    type: 'success',
                    message: '操作成功!'
                });
            }).catch((e) => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        },
        handleClickSure(row) {
            const params = {
                token: this.$store.state.token,
                projectId: this.chooseProjectId,
                indexNum: row.addIndex,
            };
            APIProject.doSureProjectPackage(params).then((res) => {
                if (res.key === 1000) {
                    this.handlePackage();
                }
            });
        },
        handlePackageRefush(){
            this.handlePackage()
            this.showPackageByIndex(1, null)
        },
        showPackageByIndex(type, row){
            if(type == 1){
                let onlineMediumList = []
                let offlineMediumList = []
                let offlineMediumListModel = {}
                row.mediumList.forEach(medium => {
                    if(medium.lineType == 1){
                        onlineMediumList.push(medium)
                    }else{
                        // offlineMediumList.push(medium)
                        if(!offlineMediumListModel[medium.lineId]){
                            offlineMediumListModel[medium.lineId] = {
                                lineId: medium.lineId,
                                mediumName: medium.mediumName,
                                totalNum: 1,
                                hasJoinNum: !medium.chooseTime ? 1 : 0,
                                numTypeName: medium.numTypeName,
                                putInCycle: medium.putInCycle,
                                id: medium.id,
                                dateList: [
                                    {
                                        chooseTime: medium.chooseTime,
                                        chooseEndTime: medium.chooseEndTime,
                                        id: medium.id,
                                    }
                                ]
                            }
                        }else{
                            offlineMediumListModel[medium.lineId].totalNum += 1
                            if(!medium.chooseTime){
                                offlineMediumListModel[medium.lineId].hasJoinNum += 1
                            }
                            offlineMediumListModel[medium.lineId].dateList.push({
                                chooseTime: medium.chooseTime,
                                chooseEndTime: medium.chooseEndTime,
                                id: medium.id,
                            })
                        }
                    }
                })
                if(Object.keys(offlineMediumListModel).length > 0){
                    offlineMediumList = Object.keys(offlineMediumListModel).map(function(t) {
                        return offlineMediumListModel[t];
                    });
                    offlineMediumList.forEach(medium => {
                        medium.dateList.sort((a, b) => {
                            return a.chooseTime - b.chooseTime
                        })
                        let dateString = ""
                        medium.dateList.forEach(dateItem => {
                            if(dateItem.chooseTime && dateItem.chooseEndTime){
                                dateString += this.formatterDate(dateItem.chooseTime) + "至" + this.formatterDate(dateItem.chooseEndTime) + "; "
                            }
                        })
                        medium.dateString = dateString
                    })
                }
                this.onlineMediumList = onlineMediumList
                this.offlineMediumList = offlineMediumList
                this.chooseShowAddIndex = row.addIndex
            }
            this.showPackage(1)
        },
        formatterDate(time) {
            return this.$moment(time).format("YYYY-MM-DD");
        },
        delPackage(row){
            this.$confirm('此操作将永久删除该配包, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.handleClickDel(row)
                this.$message({
                    type: 'success',
                    message: '删除成功!'
                });
            }).catch((e) => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        },
        handleClickDel(row) {
            const params = {
                token: this.$store.state.token,
                projectId: this.chooseProjectId,
                indexNum: row.addIndex,
            };
            APIProject.doDelProjectPackage(params).then((res) => {
                if (res.key === 1000) {
                    this.handlePackage();
                }
            });
        },
        objectSpanMethodMediumList({ row, column, rowIndex, columnIndex }) {
            if(columnIndex == 0){
                const _row = row.spanArr[rowIndex];
                const _col = _row > 0 ? 1 : 0;
                return { rowspan: _row, colspan: _col };
            }
        },
        goPackageDialog(){
            let that = this
            this.searchLineForm = {
                offlineKeyword: '',
                userType: null,
                keyword: '',
                offlineType: null,
            };
            this.pageNumOffline = 1;
            this.pageSizeOffline = 10;
            this.getSysLabel20();
            this.getSysLabel21();
            this.pageNumOnline = 1;
            this.pageSizeOnline = 10;
            this.getOnlinePost();
            this.choosePackageDialog = true;
        },
        getSysLabel20() {
            this.$bus.$emit("show-loading", true);
            const params = {
                token: this.$store.state.token,
                sysLabelIds: '31',
            };
            APISysLabel.getSysLabelValueManageList(params).then((res) => {
                if (res.key === 1000) {
                    this.offlineTypeList = res.result.data[31];
                    this.searchLineForm.offlineType = this.offlineTypeList[0].id;
                    this.getOfflinePost();
                }
                this.$bus.$emit("show-loading", false);
            });
        },
        getSysLabel21() {
            this.$bus.$emit("show-loading", true);
            const params = {
                token: this.$store.state.token,
                sysLabelIds: '21',
            };
            APISysLabel.getSysLabelValueManageList(params).then((res) => {
                if (res.key === 1000) {
                this.onlineUserType = res.result.data[21];
                }
                this.$bus.$emit("show-loading", false);
            });
        },
        handleCurrentChangeOnline(e) {
            this.pageNumOnline = e;
            this.getOnlinePost();
        },
        rePostsOnline(){
            this.pageNumOnline = 1
            this.dataOnlineList = []
            this.getOnlinePost()
        },
        getOnlinePost() {
            this.$bus.$emit("show-loading", true);
            const params = {
                token: this.$store.state.token,
                pageNum: this.pageNumOnline,
                pageSize: this.pageSizeOnline
            };
            if (this.searchLineForm.keyword) {
                params.keyword = this.searchLineForm.keyword;
            }
            if (this.searchLineForm.userType) {
                params.userType = this.searchLineForm.userType;
            }
            APIMedium.getMediumOnlineList(params).then((res) => {
                if (res.key === 1000) {
                    this.totalOnline = res.result.count;
                    res = res.result.list;
                    res.forEach(item => {
                        item.chooseNum = null
                        item.num2 = 1
                        if(this.chooseOnlineList && this.chooseOnlineList.length > 0){
                            this.chooseOnlineList.forEach(item1 => {
                                if(item1.id === item.id){
                                    item.chooseNum = item1.chooseNum
                                    item.num2 = item1.num2 ? item1.num2 : 1
                                }
                            })
                        }
                    })
                    this.dataOnlineList = res;
                }
                this.$bus.$emit("show-loading", false);
            });
        },
        handleCurrentChangeOffline(e) {
            this.pageNumOffline = e;
            this.getOfflinePost();
        },
        rePostsOffline(){
            this.pageNumOffline = 1
            this.dataOfflineList = []
            this.getOfflinePost()
        },
        getOfflinePost() {
            this.$bus.$emit("show-loading", true);
            const params = {
                token: this.$store.state.token,
                pageNum: this.pageNumOffline,
                pageSize: this.pageSizeOffline
            };
            if (this.searchLineForm.offlineKeyword) {
                params.keyword = this.searchLineForm.offlineKeyword;
            }
            if (this.searchLineForm.offlineType) {
                params.excelShowTitleId = this.searchLineForm.offlineType;
            }
            APIMedium.getMediumOfflineList(params).then((res) => {
                if (res.key === 1000) {
                this.totalOffline = res.result.count;
                res = res.result.list;
                res.forEach(item => {
                    item.chooseNum = null
                    item.num2 = 1
                    if (item.startTime){
                        item.createDate = this.$moment(item.startTime).format("YYYY-MM-DD");
                    }
                    if (item.expirationTime){
                        item.expirationDate = this.$moment(item.expirationTime).format("YYYY-MM-DD");
                    }
                    if (this.chooseOfflineList && this.chooseOfflineList.length > 0){
                        this.chooseOfflineList.forEach(item1 => {
                            if(item1.id === item.id){
                                item.chooseNum = item1.chooseNum
                                item.num = item1.chooseNum
                                item.num2 = item1.num2 ? item1.num2 : 1
                            }
                        })
                    }
                })
                this.dataOfflineList = res;
                }
                this.$bus.$emit("show-loading", false);
            });
        },
        closeDateCalendarDialog(){
            this.calendarStartTime = new Date().getTime()
            this.calendarEndTime = this.calendarStartTime
            this.dataPackageOfflineList = []
            this.calendarScrollLeftStatus = true
            this.calendarType = 1;
        },
        scrollStartCalendar(val){
            // 日历滑到最左边了
            this.getLastMonthStart(new Date(val.dateTime))
            this.getLastMonthEnd(new Date(val.dateTime))
            this.$nextTick(() => {
                this.showPackage(2)
            })
        },
        getLastMonthStart(currentDate){
            // 获取上个月的第一天
            // 将月份减1
            currentDate.setMonth(currentDate.getMonth() - 1);
            // 将日期设置为1
            currentDate.setDate(1);
            // 获取上个月的第一天
            let firstDayOfLastMonth = new Date(currentDate.getTime());
            this.calendarStartTime = firstDayOfLastMonth.getTime();
        },
        getLastMonthEnd(currentDate){
            // 获取上个月的最后一天
            // 将月份减1
            currentDate.setMonth(currentDate.getMonth());
            currentDate.setDate(0);
            currentDate.setHours(23, 59, 59, 999);
            let firstDayOfLastMonth = new Date(currentDate.getTime());
            this.calendarEndTime = firstDayOfLastMonth.getTime();
        },
        scrollEndCalendar(val){
            // 日历滑到最右边了
            this.getNextMonthStart(new Date(val.dateTime))
            this.getNextMonthEnd(new Date(val.dateTime))
            this.$nextTick(() => {
                this.showPackage(2)
            })
        },
        getNextMonthStart(currentDate){
            // 获取下个月的第一天
            // 将月份加1
            currentDate.setMonth(currentDate.getMonth() + 2);
            // 将日期设置为1
            currentDate.setDate(0);
            currentDate.setHours(0,0,0,0);
            // 获取下个月的第一天
            let firstDayOfNextMonth = new Date(currentDate.getTime());
            firstDayOfNextMonth.setDate(1);
            this.calendarStartTime = firstDayOfNextMonth.getTime();
        },
        getNextMonthEnd(currentDate){
            // 获取下个月的最后一天
            let lastDayOfNextMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 2, 0, 23, 59, 59, 999)
            this.calendarEndTime = lastDayOfNextMonth.getTime();
        },
        exportPackage(row){
            // this.tableLoading = true;
            const params = {
                token: this.$store.state.token,
                projectId: this.chooseProjectId,
                indexNum: row.addIndex,
            };
            APIProject.doExportPackage(params).then((res) => {
                if (res) {
                    const content = res.data;
                    const blob = new Blob([content]);
                    // 从response的headers中获取filename,
                    // 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名;
                    var contentDisposition = res.headers["content-disposition"];
                    var patt = new RegExp("filename=([^;]+\\.[^\\.;]+);*");
                    var result = patt.exec(contentDisposition);
                    const fileName = decodeURI(result[1]);
                    if ("download" in document.createElement("a")) {
                        // 非IE下载
                        const elink = document.createElement("a");
                        elink.download = fileName;
                        elink.style.display = "none";
                        elink.href = URL.createObjectURL(blob);
                        document.body.appendChild(elink);
                        elink.click();
                        URL.revokeObjectURL(elink.href); // 释放URL 对象
                        document.body.removeChild(elink);
                    } else {
                        // IE10+下载
                        navigator.msSaveBlob(blob, fileName);
                    }
                }
            });
        },
        cleanTableSelect() {
            let that = this;
            setTimeout(()=>{
                that.$refs.onlineTable.clearSelection();
                that.$refs.offlineTable.clearSelection();
            }, 500)
        },
        get_row_key(row){
            return row.id;
        },
        doSurePackageDialogVisible(){
            let list = []
            let needAddOnlineNum = false
            let needAddOfflineNum = false
            if(this.chooseOnlineList && this.chooseOnlineList.length > 0){
                this.chooseOnlineList.forEach(item => {
                    if(!item.chooseNum){
                        needAddOnlineNum = true
                    }
                    let dto = {
                        mediumId: item.id,
                        mediumType: 1,
                        num: parseInt(item.chooseNum),
                        num2: parseInt(item.num2),
                    }
                    this.dataOnlineList.forEach(item2 => {
                        if(item2.id == item.id){
                            dto.num = parseInt(item2.chooseNum)
                            dto.num2 = parseInt(item2.num2)
                        }
                    })
                    list.push(dto);
                })
            }
            if(this.chooseOfflineList && this.chooseOfflineList.length > 0){
                this.chooseOfflineList.forEach(item => {
                    if(!item.chooseNum){
                        needAddOfflineNum = true
                    }
                    let dto = {
                        mediumId: item.id,
                        mediumType: 2,
                        num: parseInt(item.chooseNum),
                        num2: parseInt(item.num2),
                    }
                    this.dataOfflineList.forEach(item2 => {
                        if(item2.id == item.id){
                            dto.num = parseInt(item2.chooseNum)
                            dto.num2 = parseInt(item2.num2)
                        }
                    })
                    list.push(dto);
                })
            }
            if(needAddOnlineNum){
                this.$message({
                    message: '请输入线上媒体的数量',
                    type: 'error'
                });
                return;
            }
            if(needAddOfflineNum){
                this.$message({
                    message: '请输入线下媒体的数量',
                    type: 'error'
                });
                return;
            }
            if(!list || list.length == 0){
                this.$message({
                    message: '请选择媒体',
                    type: 'error'
                });
                return;
            }
            
            let params = {
                projectId: this.chooseProjectId,
                mediums: JSON.stringify(list)
            }
            if(this.chooseAddIndex){
                params.chooseAddIndex = this.chooseAddIndex
            }
            APIProject.doPackageManageProject(params).then((res) => {
                if (res.key === 1000) {
                    this.handlePackage(this.chooseProjectId)
                    this.choosePackageDialog = false;
                }
            });
        },
        handleSelectionChangePackageOnlineList(val){
            this.chooseOnlineList = val
        },
        handleSelectionChangePackageOfflineList(val){
            this.chooseOfflineList = val
        },
        showPackage(type){
            this.calendarScrollLeftStatus = false;
            if(type == 1){
                this.getLastMonthStart(new Date())
                this.getNextMonthEnd(new Date())
                this.dataPackageOfflineList = []
                this.projectChooseMap = {}
                this.calendarType = this.calendarType + 1;
            }
            let that = this;
            let params = {
                startTime: this.calendarStartTime,
                endTime: this.calendarEndTime,
            }
            if(this.chooseProjectId){
                params.chooseProjectId = this.chooseProjectId;
            }
            // if(this.chooseShowAddIndex){
            //     params.addIndex = this.chooseShowAddIndex
            // }
            APIProject.viewOfflineHasPackageProjectList(params).then((res) => {
                if (res.key === 1000) {
                    let result = res.result
                    let list = result.list
                    let qList = []
                    let projectChooseMap = this.projectChooseMap
                    list.forEach(item => {
                        if(item.projectMsgDTOList && item.projectMsgDTOList.length > 0){
                            item.projectMsgDTOList.forEach(projectItem => {
                                if(projectItem && projectItem.chooseTime){
                                    projectItem.date = this.$moment(projectItem.chooseTime).format("yyyy-MM-DD")
                                    if(projectChooseMap[item.id + '-' + this.$moment(projectItem.chooseTime).format("YYYY-MM-DD")]){
                                        let hasJoin = false;
                                        projectChooseMap[item.id + '-' + this.$moment(projectItem.chooseTime).format("YYYY-MM-DD")].forEach(aItem => {
                                            if(aItem.id == projectItem.id){
                                                hasJoin = true
                                            }
                                        })
                                        if(!hasJoin){
                                            projectChooseMap[item.id + '-' + this.$moment(projectItem.chooseTime).format("YYYY-MM-DD")].push(projectItem)
                                        }
                                    }else{
                                        projectChooseMap[item.id + '-' + this.$moment(projectItem.chooseTime).format("YYYY-MM-DD")] = [projectItem]
                                    }
                                }
                            })
                        }
                    })
                    this.projectChooseMap = projectChooseMap
                    list.forEach(item => {
                        for(var i = 0; i < item.num; i++){
                            item.rank = i;
                            qList.push(JSON.parse(JSON.stringify(item)))
                        }
                    })
                    qList.forEach(item => {
                        item.projectMsgDTOList = item.projectList
                    })
                    let offlineList = []
                    qList.forEach(item => {
                        let projectMap = {}
                        let dto = item
                        dto.chooseNum = item.num
                        dto.num2 = 1
                        if(dto.projectMsgDTOList && dto.projectMsgDTOList.length > 0){
                            dto.projectChooseList = dto.projectMsgDTOList
                            dto.projectMsgDTOList.forEach(projectItem => {
                                if(projectItem && projectItem.chooseTime){
                                    projectItem.date = this.$moment(projectItem.chooseTime).format("YYYY-MM-DD");
                                    let a = projectMap[projectItem.date];
                                    if(a){
                                        a.push(projectItem.projectName);
                                    }else{
                                        projectMap[projectItem.date] = [projectItem.projectName];
                                    }
                                }
                            })
                        }
                        dto.projectMap = projectMap;
                        offlineList.push(dto)
                    })
                    let dtoList = []
                    dtoList = offlineList
                    let showOfflineList = [
                        {
                            name: ''
                        },
                    ]
                    let showList = showOfflineList.concat(dtoList)
                    that.dataPackageOfflineList = JSON.parse(JSON.stringify(showList))
                    this.calendarType = this.calendarType + 1;
                    if(type == 1){
                        that.dateCalendarDialog = true
                    }
                }
            });
        },
        updatePackage(row){
            let that = this
            this.packageLoading = true
            this.chooseAddIndex = row.addIndex
            this.searchLineForm = {
                offlineKeyword: '',
                userType: null,
                keyword: '',
                offlineType: null,
            };
            this.pageNumOffline = 1;
            this.pageSizeOffline = 10;
            this.getSysLabel20();
            this.getSysLabel21();
            this.pageNumOnline = 1;
            this.pageSizeOnline = 10;
            this.getOnlinePost();
            setTimeout(()=>{
                that.showUpdatePackage(row)
            }, 1000)
        },
        showUpdatePackage(row){
            let that = this
            let params = {
                projectId: this.chooseProjectId,
                indexNum: row.addIndex,
            }
            APIProject.viewPackageManageProjectMsg(params).then((res) => {
                if (res.key === 1000) {
                    let result = res.result
                    let list = result.list
                    let onlineList = []
                    let offlineList = []
                    let offlineNumMap = {}
                    list.forEach(item => {
                        if(item.lineType == 1){
                            let dto = item.mediumOnline
                            that.dataOnlineList.forEach(onlineItem => {
                                if(onlineItem.id == dto.id){
                                    onlineItem.chooseNum = item.num
                                    onlineItem.num2 = item.num2
                                    onlineList.push(onlineItem)
                                }
                            })
                        }else{
                            let dto = item.mediumOffline
                            that.dataOfflineList.forEach(offlineItem => {
                                if(offlineItem.id == dto.id){
                                    let a = offlineNumMap[dto.id]
                                    if(a){
                                        offlineNumMap[dto.id] = a + 1
                                    }else{
                                        offlineNumMap[dto.id] = 1
                                    }
                                    offlineItem.chooseNum = item.num
                                    offlineItem.num2 = item.num2
                                    offlineList.push(offlineItem)
                                }
                            })
                        }
                    })
                    onlineList.forEach(item => {
                        that.chooseOnlineList.push(item)
                        that.dataOnlineList.forEach(onlineItem => {
                            if(onlineItem.id == item.id){
                                onlineItem.chooseNum = item.chooseNum
                                onlineItem.num2 = item.num2
                            }
                        })
                    })
                    offlineList.forEach(item => {
                        that.chooseOfflineList.push(item)
                        that.dataOfflineList.forEach(offlineItem => {
                            if(offlineItem.id == item.id){
                                let b = offlineItem.putInCycle
                                let putNum = 1;
                                // if(b.includes("周")){
                                //     putNum = b.split("周")[0]
                                // }else if(b.includes("月")){
                                //     putNum = b.split("月")[0]
                                // }
                                offlineItem.chooseNum = Math.floor(offlineNumMap[offlineItem.id] / putNum)
                            }
                        })
                    })
                    that.packageLoading = false
                    that.choosePackageDialog = true;
                    that.$nextTick(()=>{
                        that.dataOnlineList = JSON.parse(JSON.stringify(that.dataOnlineList))
                        onlineList.forEach(item => {
                            that.$refs.onlineTable.toggleRowSelection(item, true);
                        })
                        that.dataOfflineList = JSON.parse(JSON.stringify(that.dataOfflineList))
                        offlineList.forEach(item => {
                            that.$refs.offlineTable.toggleRowSelection(item, true);
                        })
                    })
                }
            });
        },
        handleSelectionChangePackage(val){
        },
        handlePackage(){
            this.chooseAddIndex = null
            let params = {
                projectId: this.chooseProjectId,
            }
            APIProject.viewPackageManageProjectList(params).then((res) => {
                if (res.key === 1000) {
                    let result = res.result
                    let list = result.list
                    list.forEach(listItem => {
                        listItem.position = 0;
                        listItem.spanArr = [];
                        let onLineList = [];
                        let offLineList = []
                        let offLineShowList = []
                        listItem.mediumList.forEach((item, index) => {
                            item.chooseDate = this.$moment(item.chooseTime).format("YYYY-MM-DD");
                            item.hasSame = false;
                            if(item.lineType == 1){
                                onLineList.push(item)
                            }else{
                                offLineList.push(item)
                            }
                            let offlineMediumListModel = {}
                            offLineList.forEach(medium => {
                                if(!offlineMediumListModel[medium.lineId]){
                                    offlineMediumListModel[medium.lineId] = {
                                        ...medium,
                                        totalNum: 1,
                                        hasJoinNum: !medium.chooseTime ? 1 : 0,
                                        dateList: [
                                            {
                                                chooseTime: medium.chooseTime,
                                                chooseEndTime: medium.chooseEndTime,
                                                id: medium.id,
                                            }
                                        ]
                                    }
                                }else{
                                    offlineMediumListModel[medium.lineId].totalNum += 1
                                    if(!medium.chooseTime){
                                        offlineMediumListModel[medium.lineId].hasJoinNum += 1
                                    }
                                    offlineMediumListModel[medium.lineId].dateList.push({
                                        chooseTime: medium.chooseTime,
                                        chooseEndTime: medium.chooseEndTime,
                                        id: medium.id,
                                    })
                                }
                            })
                            if(Object.keys(offlineMediumListModel).length > 0){
                                let offlineMediumList = Object.keys(offlineMediumListModel).map(function(t) {
                                    return offlineMediumListModel[t];
                                });
                                offlineMediumList.forEach(medium => {
                                    medium.dateList.sort((a, b) => {
                                        return a.chooseTime - b.chooseTime
                                    })
                                    let dateString = ""
                                    medium.dateList.forEach(dateItem => {
                                        if(dateItem.chooseTime && dateItem.chooseEndTime){
                                            dateString += this.formatterDate(dateItem.chooseTime) + "至" + this.formatterDate(dateItem.chooseEndTime) + "; "
                                        }
                                    })
                                    medium.dateString = dateString
                                })
                                offLineShowList = offlineMediumList
                            }
                        });
                        listItem.lineList = [...onLineList,...offLineShowList]
                        listItem = JSON.parse(JSON.stringify(listItem))
                    })
                    this.packageList = list
                }
            });
        },
    }
};
</script>
<style scoped>
</style>
<style lang="sass" scoped>
</style>